Merged [13770]: Enabled saving ICQ aliases set in Adium to the server. Fixes #466
[adiumx.git] / Gaim Service / ESGaimICQAccountViewController.m
blobc42ea1a5bd107081977406626b659088eff55bc9
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11  * Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along with this program; if not,
14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15  */
17 #import "ESGaimICQAccountViewController.h"
18 #import <Adium/AIAccount.h>
19 #import <AIUtilities/AIPopUpButtonAdditions.h>
20 #import <AIUtilities/AIMenuAdditions.h>
22 @interface ESGaimICQAccountViewController (PRIVATE)
23 - (NSMenu *)encodingMenu;
24 - (void)addEncodingItemsWithNames:(NSArray *)inArray withTitle:(NSString *)inTitle toMenu:(NSMenu *)menu;
25 @end
26                                                                                    
27 @implementation ESGaimICQAccountViewController
29 - (NSString *)nibName{
30     return(@"ESGaimICQAccountView");
34 - (void)awakeFromNib
36         [super awakeFromNib];
37         
38         [popUp_encoding setMenu:[self encodingMenu]];   
41 //Configure controls
42 - (void)configureForAccount:(AIAccount *)inAccount
44     [super configureForAccount:inAccount];
45         [popUp_encoding selectItemWithRepresentedObject:[account preferenceForKey:KEY_ICQ_ENCODING
46                                                                                                                                                 group:GROUP_ACCOUNT_STATUS]];
49 //Save controls
50 - (void)saveConfiguration
52     [super saveConfiguration];
53         [account setPreference:[[popUp_encoding selectedItem] representedObject]
54                                         forKey:KEY_ICQ_ENCODING
55                                          group:GROUP_ACCOUNT_STATUS];   
58 - (NSMenu *)encodingMenu
60         NSMenu          *menu = [[NSMenu alloc] init];
61         NSArray         *nameArray;
62         NSString        *title;
63         
64         //We'll do custom enabling/disabling and not change it after then, so we don't want auto menuItem validation
65         [menu setAutoenablesItems:NO];
66         
67         title = @"European languages";
68         nameArray = [NSArray arrayWithObjects:
69                 @"ASCII",
70                 @"ISO-8859-1",
71                 @"ISO-8859-2",
72                 @"ISO-8859-3",
73                 @"ISO-8859-4",
74                 @"ISO-8859-5",
75                 @"ISO-8859-7",
76                 @"ISO-8859-9",
77                 @"ISO-8859-10",
78                 @"ISO-8859-13",
79                 @"ISO-8859-14",
80                 @"ISO-8859-15",
81                 @"ISO-8859-16",
82                 @"KOI8-R",
83                 @"KOI8-U", 
84                 @"KOI8-RU",
85                 @"CP1250",
86                 @"CP1251",
87                 @"CP1252",
88                 @"CP1253",
89                 @"CP1254",
90                 @"CP1257",
91                 @"CP850",
92                 @"CP866",
93                 @"MacRoman",
94                 @"MacCentralEurope",
95                 @"MacIceland",
96                 @"MacCroatian",
97                 @"MacRomania",
98                 @"MacCyrillic",
99                 @"MacUkraine",
100                 @"MacGreek",
101                 @"MacTurkish",
102                 @"Macintosh",
103                 nil];
104         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
105         
106         title = @"Semitic languages";
107         nameArray = [NSArray arrayWithObjects:
108                 @"ISO-8859-6",
109                 @"ISO-8859-8",
110                 @"CP1255",
111                 @"CP1256",
112                 @"CP862",
113                 @"MacHebrew",
114                 @"MacArabic",
115                 nil];
116         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
117         
118         title = @"Japanese";
119         nameArray = [NSArray arrayWithObjects:
120                 @"EUC-JP",
121                 @"SHIFT_JIS",
122                 @"CP932",
123                 @"ISO-2022-JP",
124                 @"ISO-2022-JP-2",
125                 @"ISO-2022-JP-1",
126                 nil];
127         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
129         title = @"Chinese";
130         nameArray = [NSArray arrayWithObjects:
131                 @"EUC-CN",
132                 @"HZ",
133                 @"GBK",
134                 @"GB18030",
135                 @"EUC-TW",
136                 @"BIG5",
137                 @"CP950",
138                 @"BIG5-HKSCS",
139                 @"ISO-2022-CN",
140                 @"ISO-2022-CN-EXT",
141                 nil];
142         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
143         
144         title = @"Korean";
145         nameArray = [NSArray arrayWithObjects:
146                 @"EUC-KR",
147                 @"CP949",
148                 @"ISO-2022-KR",
149                 @"JOHAB",
150                 nil];
151         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
153         title = @"Armenian";
154         nameArray = [NSArray arrayWithObjects:
155                 @"ARMSCII-8",
156                 nil];
157         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
158         
159         title = @"Georgian";
160         nameArray = [NSArray arrayWithObjects:
161                 @"Georgian-Academy",
162                 @"Georgian-PS",
163                 nil];
164         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
165         
166         title = @"Tajik";
167         nameArray = [NSArray arrayWithObjects:
168                 @"KOI8-T",
169                 nil];
170         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
172         title = @"Thai";
173         nameArray = [NSArray arrayWithObjects:
174                 @"TIS-620",
175                 @"CP874",
176                 @"MacThai",
177                 nil];
178         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
179         
180         title = @"Laotian";
181         nameArray = [NSArray arrayWithObjects:
182                 @"MuleLao-1",
183                 @"CP1133",
184                 nil];
185         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
186         
187         title = @"Vietnamese";
188         nameArray = [NSArray arrayWithObjects:
189                 @"VISCII",
190                 @"TCVN",
191                 @"CP1258",
192                 nil];
193         [self addEncodingItemsWithNames:nameArray withTitle:title toMenu:menu];
195         /*
196                 Platform specifics
197                 HP-ROMAN8, NEXTSTEP
198                 
199                 Full Unicode
200                 UTF-8 
201          */
202         
203         return([menu autorelease]);
206 - (void)addEncodingItemsWithNames:(NSArray *)inArray withTitle:(NSString *)inTitle toMenu:(NSMenu *)menu
208         NSEnumerator    *enumerator;
209         NSString                *name;
210         NSMenuItem              *menuItem;
211     BOOL                        canIndent;
212         
213     menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:inTitle
214                                                                                                                                         target:nil
215                                                                                                                                         action:nil
216                                                                                                                          keyEquivalent:@""];
217         [menuItem setEnabled:NO];
218         [menu addItem:menuItem];
219         
220         canIndent = [menuItem respondsToSelector:@selector(setIndentationLevel:)];
221         
222         enumerator = [inArray objectEnumerator];
223         while(name = [enumerator nextObject]){
224                 menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:name
225                                                                                                                                                 target:nil
226                                                                                                                                                 action:nil
227                                                                                                                                  keyEquivalent:@""];
228                 [menuItem setRepresentedObject:name];
229                 if(canIndent) [menuItem setIndentationLevel:1];
230                 
231                 [menu addItem:menuItem];
232         }
235 @end